//
//  YJSCustomView.m
//  11111
//
//  Created by ma c on 16/4/23.
//  Copyright © 2016年 ma c. All rights reserved.
//

#import "YJSCustomView.h"
#import "YJSCustomCell.h"
#import "YJSUIColor+Extension.h"


@interface YJSCustomView ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic ,strong)UITableView *tableView;

@property (nonatomic ,strong)UILabel *label;

@property (nonatomic ,strong)UIView *titleView;


@end
static CGFloat const THeight = 64;
static CGFloat const FHeight = 44;
@implementation YJSCustomView

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.tableView];
    self.tableView.rowHeight = 88;
    
    [self.view addSubview:self.label];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.navigationItem.title = @"TOPDrr";
    [self.view addSubview:self.titleView];
    self.view.backgroundColor = [UIColor cyanColor];
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 24;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    
    if (section == 0)
    {
        return [NSString stringWithFormat:@"今天"];
    }
    else if( section == 1)
    {
        return [NSString stringWithFormat:@"昨天"];
    }
    else{
        return [NSString stringWithFormat:@"前天"];
    }
    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 6;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    YJSCustomCell *cell = [YJSCustomCell cellWithTableView:tableView];
    
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (UITableView *)tableView
{
    if (!_tableView)
    {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, THeight, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame) - THeight) style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        
       
    }
    return _tableView;
}

- (UILabel *)label
{
    if (!_label)
    {
        _label = [[UILabel alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - FHeight, CGRectGetWidth(self.view.frame), FHeight)];
        _label.text = @"添加订阅";
        _label.textAlignment = NSTextAlignmentCenter;
        _label.textColor = [UIColor colorWithHexString:@"#ffffff"];
        _label.backgroundColor = [UIColor colorWithHexString:@"#32c7c2"];
        _label.font = [UIFont systemFontOfSize:17.0];
    }
    return _label;
}

- (UIView *)titleView
{

    if (!_titleView)
    {
        _titleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,CGRectGetWidth(self.view.frame),THeight)];
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.frame = CGRectMake(10, 30, 30, 30);
//        UIImageView *btnImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"个人中心"]];
        [btn setImage:[UIImage imageNamed:@"个人中心1"] forState:UIControlStateNormal];
        [btn setImage:[UIImage imageNamed:@"个人中心"] forState:UIControlStateHighlighted];
        [_titleView addSubview:btn];
        _titleView.backgroundColor = [UIColor colorWithHexString:@"#f5f5f5"];
        
    }
    return _titleView;
}
@end
